# Copyright 2025 Guan Yewei
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:yacl.bzl", "yacl_cc_library", "yacl_cc_test")

package(default_visibility = ["//visibility:public"])

yacl_cc_library(
    name = "hash_to_curve",
    hdrs = [
        "hash_to_curve.h",
    ],
    deps = [
        ":curve25519",
        ":p256",
        ":p384",
        ":p521",
    ],
)

yacl_cc_library(
    name = "p256",
    srcs = [
        "p256.cc",
    ],
    hdrs = [
        "p256.h",
    ],
    deps = [
        ":hash_to_curve_util",
        "//yacl/base:exception",
        "//yacl/crypto/ecc:ec_point",
        "//yacl/crypto/hash:hash_utils",
        "//yacl/math/mpint",
        "@abseil-cpp//absl/strings",
    ],
)

yacl_cc_library(
    name = "p384",
    srcs = [
        "p384.cc",
    ],
    hdrs = [
        "p384.h",
    ],
    deps = [
        ":hash_to_curve_util",
        "//yacl/base:exception",
        "//yacl/crypto/ecc:ec_point",
        "//yacl/crypto/hash:hash_utils",
        "//yacl/math/mpint",
        "@abseil-cpp//absl/strings",
    ],
)

yacl_cc_library(
    name = "p521",
    srcs = [
        "p521.cc",
    ],
    hdrs = [
        "p521.h",
    ],
    deps = [
        ":hash_to_curve_util",
        "//yacl/base:exception",
        "//yacl/crypto/ecc:ec_point",
        "//yacl/crypto/hash:hash_utils",
        "//yacl/math/mpint",
        "@abseil-cpp//absl/strings",
    ],
)

yacl_cc_library(
    name = "curve25519",
    srcs = [
        "curve25519.cc",
    ],
    hdrs = [
        "curve25519.h",
    ],
    deps = [
        ":hash_to_curve_util",
        "//yacl/base:exception",
        "//yacl/crypto/ecc:ec_point",
        "//yacl/crypto/hash:hash_utils",
        "//yacl/math/mpint",
        "@abseil-cpp//absl/strings",
    ],
)

yacl_cc_library(
    name = "hash_to_curve_util",
    srcs = [
        "hash_to_curve_util.cc",
    ],
    hdrs = [
        "hash_to_curve_util.h",
    ],
    deps = [
        "//yacl/base:exception",
        "//yacl/crypto/ecc:curve_meta",
        "//yacl/crypto/ecc:ec_point",
        "//yacl/crypto/hash:hash_utils",
        "//yacl/math/mpint",
        "@abseil-cpp//absl/strings",
    ],
)

yacl_cc_test(
    name = "hash_to_curve_test",
    srcs = [
        "hash_to_curve_test.cc",
    ],
    deps = [
        ":hash_to_curve",
        "@fmt",
        "@yacl//yacl/utils:parallel",
    ],
)
